﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Model;
using Dal;
using easysql;
namespace Web.service
{
    /// <summary>
    /// ConfigService 的摘要说明
    /// </summary>
    public class ConfigService : BaseService<ConfigModel>
    {
        private ConfigDal dal = DalFactory.CreateConfigDal();

        public object queryPage(HttpContext context)
        {
            var pi = requestPageInfo(context);
            var list = dal.IQueryPage(pi);
            return new { total = pi.total, rows = list };
        }
        public void add(HttpContext context)
        {
            var model = requestModel(context);
            dal.IAddOnly(model, "名称不能重复", Restrain.Eq("name", model.name));
        }
        public void modify(HttpContext context)
        {
            var model = requestModel(context);
            dal.IModifyOnly(model, "名称不能重复", Restrain.Eq("name", model.name));
        }
        public void delById(HttpContext context)
        {
            int id = int.Parse(context.Request["id"]);
            dal.IDelById(id);
        }
    }
}